package com.smart.mobile.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.smart.model.mobile.MarketGoods;
import com.smart.util.DBUtil;

public class MarketGoodsDAO {
	protected List<MarketGoods> result = new ArrayList<MarketGoods>();
	
	public List<MarketGoods> getGoodsByMarketID( int goodsID) throws SQLException{
		MarketGoods goods;
		String sql = "select * from shop where marketID = ?";
		Connection conn = DBUtil.getConnection();
		PreparedStatement pSt =conn.prepareCall(sql);
		pSt.setInt(1,goodsID);
		ResultSet set = pSt.executeQuery();
		while(set.next()){
			goods = new MarketGoods();
			goods.setId(set.getInt("ID"));
			goods.setMarketID(set.getInt("marketID"));
			goods.setMarketname(set.getString("marketname"));
			goods.setShopkucun(set.getInt("shopkucun"));
			goods.setShopname(set.getString("shopname"));
			goods.setShoppic(set.getString("shoppic"));
			goods.setShopprice(set.getDouble("shopprice"));
			result.add(goods);
		}
		
		return result;
	}
}
